// 配置路由的模块
// 路由就是根据不同的 url 地址，动态的让根组件挂载其他组件来实现一个单页面的应用
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

// 配置路由
// 1、引入页面需要的组件
import { NewsComponent } from './components/news/news.component';
import { HomeComponent } from './components/home/home.component';
import { NewscontentComponent } from './components/newscontent/newscontent.component';
import { PostComponent } from './components/post/post.component';

const routes: Routes = [
  {path:"home",component:HomeComponent},
  {path:"news",component:NewsComponent},
  {path:"post",component:PostComponent},
  // 这里的 aid 是一个动态值
  {path:"newscontent/:aid",component:NewscontentComponent},
  {path:"**",redirectTo:"home"} //匹配不到就直接跳转到home
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
